package com.tancire.question.service.impl;

import java.util.List;
import javax.annotation.Resource;
import com.tancire.common.utils.DateUtils;
import org.springframework.stereotype.Service;
import com.tancire.question.mapper.QuestionCategoryMapper;
import com.tancire.question.domain.QuestionCategory;
import com.tancire.question.service.IQuestionCategoryService;

/**
 * 问题分类Service业务层处理
 *
 * @author chenchao
 * @date 2024-06-06
 */
@Service
public class QuestionCategoryServiceImpl implements IQuestionCategoryService {
    @Resource
    private QuestionCategoryMapper questionCategoryMapper;

    /**
     * 查询问题分类
     *
     * @param categoryId 问题分类主键
     * @return 问题分类
     */
    @Override
    public QuestionCategory selectQuestionCategoryByCategoryId(Long categoryId) {
        return questionCategoryMapper.selectQuestionCategoryByCategoryId(categoryId);
    }

    /**
     * 查询问题分类列表
     *
     * @param questionCategory 问题分类
     * @return 问题分类
     */
    @Override
    public List<QuestionCategory> selectQuestionCategoryList(QuestionCategory questionCategory) {
        return questionCategoryMapper.selectQuestionCategoryList(questionCategory);
    }

    /**
     * 新增问题分类
     *
     * @param questionCategory 问题分类
     * @return 结果
     */
    @Override
    public int insertQuestionCategory(QuestionCategory questionCategory) {
        questionCategory.setCreateTime(DateUtils.getNowDate());
        return questionCategoryMapper.insertQuestionCategory(questionCategory);
    }

    /**
     * 修改问题分类
     *
     * @param questionCategory 问题分类
     * @return 结果
     */
    @Override
    public int updateQuestionCategory(QuestionCategory questionCategory) {
        questionCategory.setUpdateTime(DateUtils.getNowDate());
        return questionCategoryMapper.updateQuestionCategory(questionCategory);
    }

    /**
     * 批量删除问题分类
     *
     * @param categoryIds 需要删除的问题分类主键
     * @return 结果
     */
    @Override
    public int deleteQuestionCategoryByCategoryIds(Long[] categoryIds) {
        return questionCategoryMapper.deleteQuestionCategoryByCategoryIds(categoryIds);
    }

    /**
     * 删除问题分类信息
     *
     * @param categoryId 问题分类主键
     * @return 结果
     */
    @Override
    public int deleteQuestionCategoryByCategoryId(Long categoryId) {
        return questionCategoryMapper.deleteQuestionCategoryByCategoryId(categoryId);
    }
}
